home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / lib / backup / ltest3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  965 b   |  57 lines

  1.  
  2. /* ltest3.c   to test c_array lib calls
  3.  */
  4.  
  5. #include <hipl_format.h>
  6. #include <stdio.h>
  7. #include <sys/types.h>
  8.  
  9. char     *Progname;
  10.  
  11.  
  12. main(argc, argv)
  13.     int       argc;
  14.     char     *argv[];
  15. {
  16.     register int i, j;
  17.     int r,c;
  18.     struct header hd;
  19.     u_char **alloc_2d_byte_array();
  20.  
  21.  
  22.  
  23.     u_char  **pic1, **pic2;
  24.  
  25.     Progname = strsave(*argv);
  26.  
  27.     read_header(&hd);
  28.     if (hd.pixel_format != PFBYTE)
  29.     perr("image pixel format must be byte");
  30.  
  31.     update_header(&hd, argc, argv);
  32.     write_header(&hd);
  33.  
  34.  
  35.     r = hd.rows;
  36.     c = hd.cols;
  37.  
  38.     fprintf(stderr, " num cols: %d, num rows: %d \n\n", c,r);
  39.  
  40.     pic1 = alloc_2d_byte_array(r,c);
  41.     pic2 = alloc_2d_byte_array(r,c); 
  42.     
  43.     read_2d_byte_array(stdin, pic1, r,c);
  44.     
  45.     for (i = 0; i < r; i++)
  46.     for (j = 0; j < c; j++)  {
  47.         pic2[i][j] = pic1[i][j]; 
  48.         fprintf(stderr, "at (%d,%d), pixel val: %d \n", 
  49.             i,j,pic1[i][j]);
  50.     }
  51.     write_2d_byte_array(stdout, pic2, r,c); 
  52.  
  53.  
  54.     return (0);
  55. }
  56.  
  57.